package cn.edu.scau.cmi.wuzewei.composite.consistent;

import java.util.HashMap;
import java.util.Map;

public class ConsistentComposite implements ConsistentComponent {
	
	public String name;
	Map<String, ConsistentComponent> mapChildren;
	ConsistentComponent Parent;

	public ConsistentComposite(ConsistentComponent parentComponent, String myname) {
		mapChildren = new HashMap<String, ConsistentComponent>();
		Parent = parentComponent;
		
		name = myname;
	}

	@Override
	public String doSomething() {
		return null;
	}
	
	@Override
	public String toString() {
		return name;
	}

	@Override
	public ConsistentComponent getParent() {
		return Parent;
	}

	@Override
	public void addChild(String name, ConsistentComponent parentComponent) {
		mapChildren.put(name, parentComponent);
	}

	@Override
	public void delete(String child) {
		mapChildren.remove(child);
	}

	@Override
	public void updateChildren(Map<String, ConsistentComponent> mapChildren) {
		this.mapChildren = mapChildren;
	}

	@Override
	public Map<String, ConsistentComponent> getChileren() {
		return mapChildren;
	}

}
